<template>
	<view>
		<!-- 循环列表 -->
		<view v-if="addList.length > 0">
			<add-address :addList="addList" :address="address" @getAdd="getAdd"></add-address>
		</view>
		<view class="u-p-30" v-else>暂无收货地址</view>

		<!-- 底部新增按钮 -->
		<view class="addAddress">
			<u-button type="error" shape="circle" @click="toAddList">
				<u-icon name="plus" color="#fff" size="28"></u-icon>新增收货地址
			</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				addList: [],
				address: ''
			}
		},
		onShow() {
			this.address = getCurrentPages().pop().route
			this.getAdd()
		},
		methods: {
			async getAdd() {
				const {
					data
				} = await this.$u.api.getAdd();
				this.addList = data;
				// console.log(data);
			},
			toAddList() {
				this.$u.route('pages/cart/add-list')
			}




		}
	}
</script>

<style lang="scss" scoped>
	.addAddress {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 40rpx;
		padding: 0 40rpx;
	}
</style>
